"use strict";
const common_vendor = require("../../common/vendor.js");
const common_share = require("../../common/share.js");
var uChartsInstance = {};
const _sfc_main = {
  onShareAppMessage() {
    return {
      title: "沁园全屋",
      imageUrl: "",
      path: "pages/index/index"
    };
  },
  data() {
    return {
      chartData: {},
      matchResultList: [],
      chartData: {},
      opts: {
        color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
        // rotate:true,
        padding: [15, 0, 5, 0],
        enableMarkLine: false,
        fontSize: 10,
        legend: {
          position: "top",
          margin: 20,
          padding: 20,
          itemGap: 20,
          fontSize: 14
          // borderWidth:1,
          // borderColor:'#ccc'
        },
        markLine: {
          type: "dash"
        },
        xAxis: {
          fontSize: 12,
          disableGrid: false,
          type: "grid",
          gridColor: "#CCCCCC",
          gridType: "line"
        },
        yAxis: {
          gridType: "dash",
          dashLength: 4,
          splitNumber: 1,
          disabled: true,
          disableGrid: true,
          data: [{
            min: 0,
            disabled: true,
            textAlign: "center"
            // unit:'tt'
          }]
        },
        extra: {
          markLine: {
            dashLength: 0
          },
          column: {
            type: "group",
            width: 20,
            activeBgColor: "#000000",
            activeBgOpacity: 0.08,
            seriesGap: 2,
            categoryGap: 10,
            barBorderRadius: [20, 20, 0, 0]
          },
          tooltip: {
            borderRadius: 5,
            showCategory: true
          }
        }
      }
    };
  },
  onReady() {
    this.cWidth = common_vendor.index.upx2px(660);
    this.cHeight = common_vendor.index.upx2px(500);
    this.getList();
  },
  methods: {
    getList() {
      const list = common_share.getMatchResultList();
      if (!list || !list.length) {
        return;
      }
      this.matchResultList = list;
      const categories = ["年耗盐量(Kg)", "加盐周期(天)", "再生周期(天)", "建议单次加盐(Kg)"];
      const series = list.map((e, index) => {
        return {
          name: e.product_model,
          data: [
            e["annual_salt_consumption"],
            e["salt_addition_interval"],
            e["regeneration_cycle"],
            e["resin_amount"]
            // e[keys[0]],
            // e[keys[1]],
            // e[keys[2]],
            // e[keys[3]],
          ]
        };
      });
      this.chartData = JSON.parse(JSON.stringify({
        categories,
        series
      }));
    },
    getServerData() {
      setTimeout(() => {
        let res = {
          categories: ["2016", "2017", "2018", "2019", "2020", "2021"],
          series: [
            {
              name: "目标值",
              data: [35, 36, 31, 33, 13, 34]
            },
            {
              name: "完成量",
              data: [18, 27, 21, 24, 6, 28]
            }
          ]
        };
        this.drawCharts("column", res);
      }, 500);
    },
    drawCharts(id, data) {
      const ctx = common_vendor.index.createCanvasContext(id, this);
      uChartsInstance[id] = new uCharts({
        categories: data.categories,
        series: data.series,
        color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
        type: "column",
        context: ctx,
        width: this.cWidth,
        height: this.cHeight,
        // animation: true,
        // background: "#FFFFFF",
        padding: [15, 0, 5, 0],
        enableMarkLine: false,
        legend: {
          position: "top",
          margin: 20,
          padding: 20,
          itemGap: 20,
          fontSize: 14
          // borderWidth:1,
          // borderColor:'#ccc'
        },
        markLine: {
          type: "dash"
        },
        xAxis: {
          disableGrid: true,
          fontSize: 12
          // rotateLabel: true,
          // rotateAngle:45, //旋转角度，默认45度
          // labelCount:5
        },
        yAxis: {
          gridType: "dash",
          dashLength: 4,
          splitNumber: 5,
          data: [
            {
              min: 0,
              disabled: true,
              textAlign: "center"
            }
          ]
        },
        extra: {
          column: {
            type: "group",
            width: 20,
            activeBgColor: "#000000",
            activeBgOpacity: 0.08,
            seriesGap: 2,
            categoryGap: 10,
            barBorderRadius: [20, 20, 0, 0]
          },
          tooltip: {
            borderRadius: 5,
            showCategory: true
          }
        }
      });
    },
    tap(e) {
      uChartsInstance[e.target.id].touchLegend(e);
      uChartsInstance[e.target.id].showToolTip(e);
    }
  }
};
if (!Array) {
  const _easycom_qiun_data_charts2 = common_vendor.resolveComponent("qiun-data-charts");
  _easycom_qiun_data_charts2();
}
const _easycom_qiun_data_charts = () => "../../uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.js";
if (!Math) {
  _easycom_qiun_data_charts();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: common_vendor.p({
      type: "column",
      opts: $data.opts,
      chartData: $data.chartData,
      background: "#fff",
      tooltipFormat: "qytip"
    })
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "C:/Users/karo/Desktop/finale/3.0/clean-water/clean-water/pages/solution-contrast/solution-contrast.vue"]]);
_sfc_main.__runtimeHooks = 2;
wx.createPage(MiniProgramPage);
